# Maintainer: Ray Donnelly <mingwandroid@gmail.com>

pkgname=procps
pkgver=3.2.8
pkgrel=2
pkgdesc="System and process monitoring utilities"
arch=('i686' 'x86_64')
url="https://procps.sourceforge.io/"
license=('GPL2')
groups=('sys-utils')
makedepends=('ncurses-devel')
depends=('msys2-runtime')
options=('!emptydirs' 'strip')
# procps-3.2.8-2.src.patch is by Cygwin's Corinna Vinschen.
source=(https://procps.sourceforge.io/$pkgname-$pkgver.tar.gz
        procps-3.2.8-2.src.patch)
sha256sums=('11ed68d8a4433b91cd833deb714a3aa849c02aea738c42e6b4557982419c1535'
            '4c45f9b8cd2cefafb2ce6b296c48ed0907910330da301f2c45e9ee77f6ca5d68')

prepare() {
  cd ${srcdir}/$pkgname-$pkgver

  patch -p2 -i ${srcdir}/procps-3.2.8-2.src.patch
}

build() {
  cd ${srcdir}/$pkgname-$pkgver
  make \
    CFLAGS+=" -I/usr/include/ncursesw" \
    CURSES=-lncursesw \
    CPPFLAGS+=" -I/usr/include/ncursesw"
}

package() {
  cd ${srcdir}/$pkgname-$pkgver
  make DESTDIR=${pkgdir} install

  # fix permissons
  find ${pkgdir}/ -type f \( -name "*.dll" -o -name "*.exe" \) | xargs chmod 0755

  mv -f ${pkgdir}/bin/* ${pkgdir}/usr/bin/
  rm -r ${pkgdir}/bin
  mv -f ${pkgdir}/sbin ${pkgdir}/usr/
}
